from core.Airtest import AppAutomation

class Logout():
    def __init__(self):
        self.kuke = AppAutomation()

    def logout(self):
        """执行登出操作"""
        self._swipe_screen()
        self._click_account_settings()
        self._logout_and_confirm()
        self._assert_logout_success()

    def _swipe_screen(self):
        """滑动屏幕"""
        self.kuke.swipe_screen("tpl1736993243803.png")

    def _click_account_settings(self):
        """点击账号设置"""
        self.kuke.click(text="账号设置")

    def _logout_and_confirm(self):
        """执行退出登录操作"""
        self.kuke.click("退出登录")
        self.kuke.click("退出")

    def _assert_logout_success(self):
        """断言用户名是否为“登录/注册”"""
        name = self.kuke.get_text("com.kuke:id/tv_nick_name")
        self.kuke.assert_equal(name, "登录/注册", msg="断言是否成功退出登录")
